/*******************************************************************************
* @file    fins_test.h
* @author  Fins
* @brief   
* @time    2020-11-18 19:27:58 Wednesday
* @codeing UTF-8
* @license
*     Copyright 2020 Fins
*
*     Licensed under the Apache License, Version 2.0 (the "License");
*     you may not use this file except in compliance with the License.
*     You may obtain a copy of the License at
*
*         http://www.apache.org/licenses/LICENSE-2.0
*
*     Unless required by applicable law or agreed to in writing, software
*     distributed under the License is distributed on an "AS IS" BASIS,
*     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*     See the License for the specific language governing permissions and
*     limitations under the License.
* @verbatim
================================================================================
                        ##### xxxxxxxxxxxxxxxxxxxxxxx #####
================================================================================
* @endverbatim
* @attention
*******************************************************************************/



/** Prevent recursive inclusion */
#ifndef __FINS_TEST_H
#define __FINS_TEST_H

/** C++ compatible */
#ifdef __cplusplus
 extern "C" {
#endif /** __cplusplus */

/* Includes start *************************************************************/
/*     Lib files ****************************** */

/*     User files ***************************** */
#include "fins_define.h"

/* Includes end ***************************************************************/

/* Exported define start ******************************************************/

#define __FT_HEAD_STR         "ftest"
#define __FT_AT_STR           "L"

#define __FT_RES_PASS_STR     "PASS    "
#define __FT_RES_FAIL_STR     "    FAIL"

#define __FT_ATTR_TESTCASE_STR     "testcase  "
#define __FT_ATTR_UNIT_STR         "  unit    "
#define __FT_ATTR_RES_STR          "    result"

#define FtPrintf            printf

/*************************************************
 * @brief RGB color
 ************************************************/
#define FINS_TEST_OUT_ENABLE_RGB 1
#if FINS_TEST_OUT_ENABLE_RGB == 1
    #define __FT_CLR_DEF                         "0"
    #define __FT_CLR_GREEN                       "32"
    #define __FT_CLR_YELLOW                      "33"
    #define __FT_CLR_RED                         "31"
    #define __FT_CLR_BLUE                        "34"

    #define __FT_OUT_SET(pram)    \
        FtPrintf("\033[%sm",pram)
#else 
    #define __FT_CLR_DEF 
    #define __FT_CLR_GREEN
    #define __FT_CLR_YELLOW
    #define __FT_CLR_RED
    #define __FT_CLR_BLUE

    #define __FT_OUT_SET(pram)
#endif /* FINS_TEST_OUT_ENABLE_RGB == 1 */

#define __FT_FORMENT_PRINTF(res, attr, fmt,...)                                \
    FtPrintf("%s:[ %s ][ %s ] ", __FT_HEAD_STR, res, attr);                    \
    FtPrintf(fmt, ##__VA_ARGS__);                                              \
    FtPrintf("\r\n");

#define FT_TRUE(expr)  FtTrue(#expr, (expr), __LINE__)
#define FT_FALSE(expr)  FtFalse(#expr, (expr), __LINE__)
#define FT_EQ(data1, data2)  FtEq(#data1, data1, #data2, data2, __LINE__)

/* Exported define end ********************************************************/

/* Exported typedef start *****************************************************/





/* Exported typedef end *******************************************************/

/* Exported variable start ****************************************************/





/* Exported variable end ******************************************************/

/* Exported function start ****************************************************/

extern void FtTrue(const fsint8* experStr, fbool exprRes, fsint32 line);
extern void FtFalse(const fsint8* experStr,fbool exprRes, fsint32 line);
extern void FtEq(
    const fchar* data1Str, fsint32 data1,
    const fchar* data2Str, fsint32 data2, 
    fsint32 line);



/* Exported function end ******************************************************/

/** C++ compatible */
#ifdef __cplusplus
}
#endif /** __cplusplus */

#endif /** __FINS_TEST_H */
////////////////////////////////- END OF FILE  -////////////////////////////////
